package com.fy.market.activity.service.rule.chain;

import com.fy.market.strategy.service.rule.chain.ILogicChain;

/**
 * @author fwq
 * @description 抽奖活动规则链装配接口
 * @date 2025-10-11 13:20
 */
public interface IActionChainArmory {

    IActionChain next();

    /**
     * 拼接下一个抽奖活动规则链节点
     * @param next 下一个抽奖活动规则链节点
     * @return 抽奖活动规则链
     */
    IActionChain appendNext(IActionChain next);

    // 获取当前节点名称
    default String getNodeName() {
        return this.getClass().getSimpleName();
    }

    // 获取责任链完整信息
    default String getChainInfo() {
        StringBuilder chainInfo = new StringBuilder();
        IActionChain current = (IActionChain) this;
        int index = 1;

        while (current != null) {
            chainInfo.append("节点").append(index).append(": ").append(current.getNodeName());
            current = current.next();
            if (current != null) {
                chainInfo.append(" -> ");
            }
            index++;
        }

        return chainInfo.toString();
    }
}
